﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.Command;
using Register.DALFactory;
using Register.IDAL;
using Register.Model;
namespace Register.BLL
{
    /// <summary> 
    /// FileName: OutpatientBLL.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/7/10 10:57:04    
    /// </summary>
  public  class OutpatientBLL
  {
      private static String typeNameKey = "IOutpatientDALKey";
        #region 获取患者就诊信息
      public static List<Model.RegisterInfo> GetPagedOutpatientInfo(int size, int pageIndex, string where)
        {
            IOutpatientDAL iOutpatientInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);
            try
            {
                return iOutpatientInfo.GetPagedOutpatientInfo(size,pageIndex,where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
      public static int GetOutpatientInfoCount(string where)
        {
            IOutpatientDAL iOutpatientInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);

            try
            {
                return iOutpatientInfo.GetOutpatientInfoCount(where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
      #region 添加患者就诊信息
      public static bool AddOutpatientInfo(Model.Outpatient model)
      {
          IOutpatientDAL iOutpatientInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);
          try
          {
              if (iOutpatientInfo.AddOutpatientInfo(model) > 0)
                  return true;
              else
                  return false;
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      #endregion
      #region 检查患者是否就诊
      public static bool Exists(string registerID)
      {
          IOutpatientDAL iPatientInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);

          try
          {
              bool flag = iPatientInfo.Exists(registerID);
              return flag;
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }

      #endregion
      #region 根据医生编号获取医生所对应的门诊类型
      public static string GetOutpatientTypeById(string doctorID)
      {
          IOutpatientDAL outpatient = DALFactory<IOutpatientDAL>.Create(typeNameKey);
          try
          {
              return outpatient.GetOutpatientType(doctorID);

          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      #endregion
      #region 查看患者就诊信息
      public static List<Model.Outpatient> GetOutpatientInfo(string outpatientID)
      {
          IOutpatientDAL ipatient = DALFactory<IOutpatientDAL>.Create(typeNameKey);
          try
          {
              return ipatient.GetOutpatientInfo(outpatientID);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      #endregion
      #region 多条件查询
      public static List<Model.Outpatient> GetPagedSearchInfo(int size, int pageIndex, string where)
      {
          IOutpatientDAL iSearchInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);
          try
          {
              return iSearchInfo.GetPagedSearchInfo(size,pageIndex,where);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      public static int GetSearchCount(string where)
      {
          IOutpatientDAL iSearchInfo = DALFactory<IOutpatientDAL>.Create(typeNameKey);

          try
          {
              return iSearchInfo.GetSearchCount(where);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }

      #endregion
  }
}
